3.54 \(\int \frac{\sin ^2(c+d x)}{a+b \tan (c+d x)} \, dx\)

Optimal. Leaf size=94 \[ -\frac{\cos ^2(c+d x) (a \tan (c+d x)+b)}{2 d \left (a^2+b^2\right )}+\frac{a^2 b \log (a \cos (c+d x)+b \sin (c+d x))}{d \left (a^2+b^2\right )^2}+\frac{a x \left (a^2-b^2\right )}{2 \left (a^2+b^2\right )^2} \]

[Out]

(a*(a^2 - b^2)*x)/(2*(a^2 + b^2)^2) + (a^2*b*Log[a*Cos[c + d*x] + b*Sin[c + d*x]])/((a^2 + b^2)^2*d) - (Cos[c
+ d*x]^2*(b + a*Tan[c + d*x]))/(2*(a^2 + b^2)*d)

________________________________________________________________________________________

Rubi [A]  time = 0.163218, antiderivative size = 94, normalized size of antiderivative = 1., number of steps used = 7, number of rules used = 6, integrand size = 21, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.286, Rules used = {3516, 1647, 801, 635, 203, 260} \[ -\frac{\cos ^2(c+d x) (a \tan (c+d x)+b)}{2 d \left (a^2+b^2\right )}+\frac{a^2 b \log (a \cos (c+d x)+b \sin (c+d x))}{d \left (a^2+b^2\right )^2}+\frac{a x \left (a^2-b^2\right )}{2 \left (a^2+b^2\right )^2} \]

Antiderivative was successfully verified.

[In]

Int[Sin[c + d*x]^2/(a + b*Tan[c + d*x]),x]

[Out]

(a*(a^2 - b^2)*x)/(2*(a^2 + b^2)^2) + (a^2*b*Log[a*Cos[c + d*x] + b*Sin[c + d*x]])/((a^2 + b^2)^2*d) - (Cos[c
+ d*x]^2*(b + a*Tan[c + d*x]))/(2*(a^2 + b^2)*d)

Rule 3516

Int[sin[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Dist[b/f, Subst[Int
[(x^m*(a + x)^n)/(b^2 + x^2)^(m/2 + 1), x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, n}, x] && IntegerQ[m/
2]

Rule 1647

Int[(Pq_)*((d_) + (e_.)*(x_))^(m_.)*((a_) + (c_.)*(x_)^2)^(p_), x_Symbol] :> With[{Q = PolynomialQuotient[(d +
 e*x)^m*Pq, a + c*x^2, x], f = Coeff[PolynomialRemainder[(d + e*x)^m*Pq, a + c*x^2, x], x, 0], g = Coeff[Polyn
omialRemainder[(d + e*x)^m*Pq, a + c*x^2, x], x, 1]}, Simp[((a*g - c*f*x)*(a + c*x^2)^(p + 1))/(2*a*c*(p + 1))
, x] + Dist[1/(2*a*c*(p + 1)), Int[(d + e*x)^m*(a + c*x^2)^(p + 1)*ExpandToSum[(2*a*c*(p + 1)*Q)/(d + e*x)^m +
 (c*f*(2*p + 3))/(d + e*x)^m, x], x], x]] /; FreeQ[{a, c, d, e}, x] && PolyQ[Pq, x] && NeQ[c*d^2 + a*e^2, 0] &
& LtQ[p, -1] && ILtQ[m, 0]

Rule 801

Int[(((d_.) + (e_.)*(x_))^(m_)*((f_.) + (g_.)*(x_)))/((a_) + (c_.)*(x_)^2), x_Symbol] :> Int[ExpandIntegrand[(
(d + e*x)^m*(f + g*x))/(a + c*x^2), x], x] /; FreeQ[{a, c, d, e, f, g}, x] && NeQ[c*d^2 + a*e^2, 0] && Integer
Q[m]

Rule 635

Int[((d_) + (e_.)*(x_))/((a_) + (c_.)*(x_)^2), x_Symbol] :> Dist[d, Int[1/(a + c*x^2), x], x] + Dist[e, Int[x/
(a + c*x^2), x], x] /; FreeQ[{a, c, d, e}, x] &&  !NiceSqrtQ[-(a*c)]

Rule 203

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1*ArcTan[(Rt[b, 2]*x)/Rt[a, 2]])/(Rt[a, 2]*Rt[b, 2]), x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 260

Int[(x_)^(m_.)/((a_) + (b_.)*(x_)^(n_)), x_Symbol] :> Simp[Log[RemoveContent[a + b*x^n, x]]/(b*n), x] /; FreeQ
[{a, b, m, n}, x] && EqQ[m, n - 1]

Rubi steps

\begin{align*} \int \frac{\sin ^2(c+d x)}{a+b \tan (c+d x)} \, dx &=\frac{b \operatorname{Subst}\left (\int \frac{x^2}{(a+x) \left (b^2+x^2\right )^2} \, dx,x,b \tan (c+d x)\right )}{d}\\ &=-\frac{\cos ^2(c+d x) (b+a \tan (c+d x))}{2 \left (a^2+b^2\right ) d}-\frac{\operatorname{Subst}\left (\int \frac{-\frac{a^2 b^2}{a^2+b^2}+\frac{a b^2 x}{a^2+b^2}}{(a+x) \left (b^2+x^2\right )} \, dx,x,b \tan (c+d x)\right )}{2 b d}\\ &=-\frac{\cos ^2(c+d x) (b+a \tan (c+d x))}{2 \left (a^2+b^2\right ) d}-\frac{\operatorname{Subst}\left (\int \left (-\frac{2 a^2 b^2}{\left (a^2+b^2\right )^2 (a+x)}-\frac{a b^2 \left (a^2-b^2-2 a x\right )}{\left (a^2+b^2\right )^2 \left (b^2+x^2\right )}\right ) \, dx,x,b \tan (c+d x)\right )}{2 b d}\\ &=\frac{a^2 b \log (a+b \tan (c+d x))}{\left (a^2+b^2\right )^2 d}-\frac{\cos ^2(c+d x) (b+a \tan (c+d x))}{2 \left (a^2+b^2\right ) d}+\frac{(a b) \operatorname{Subst}\left (\int \frac{a^2-b^2-2 a x}{b^2+x^2} \, dx,x,b \tan (c+d x)\right )}{2 \left (a^2+b^2\right )^2 d}\\ &=\frac{a^2 b \log (a+b \tan (c+d x))}{\left (a^2+b^2\right )^2 d}-\frac{\cos ^2(c+d x) (b+a \tan (c+d x))}{2 \left (a^2+b^2\right ) d}-\frac{\left (a^2 b\right ) \operatorname{Subst}\left (\int \frac{x}{b^2+x^2} \, dx,x,b \tan (c+d x)\right )}{\left (a^2+b^2\right )^2 d}+\frac{\left (a b \left (a^2-b^2\right )\right ) \operatorname{Subst}\left (\int \frac{1}{b^2+x^2} \, dx,x,b \tan (c+d x)\right )}{2 \left (a^2+b^2\right )^2 d}\\ &=\frac{a \left (a^2-b^2\right ) x}{2 \left (a^2+b^2\right )^2}+\frac{a^2 b \log (\cos (c+d x))}{\left (a^2+b^2\right )^2 d}+\frac{a^2 b \log (a+b \tan (c+d x))}{\left (a^2+b^2\right )^2 d}-\frac{\cos ^2(c+d x) (b+a \tan (c+d x))}{2 \left (a^2+b^2\right ) d}\\ \end{align*}

Mathematica [A]  time = 0.722595, size = 170, normalized size = 1.81 \[ -\frac{2 b^2 \left (a^2+b^2\right ) \cos ^2(c+d x)+2 a b \left (a^2+b^2\right ) \tan ^{-1}(\tan (c+d x))+a \left (b \left (a^2+b^2\right ) \sin (2 (c+d x))+2 a \left (-2 b^2 \log (a+b \tan (c+d x))+\left (a \sqrt{-b^2}+b^2\right ) \log \left (\sqrt{-b^2}-b \tan (c+d x)\right )+\left (b^2-a \sqrt{-b^2}\right ) \log \left (\sqrt{-b^2}+b \tan (c+d x)\right )\right )\right )}{4 b d \left (a^2+b^2\right )^2} \]

Antiderivative was successfully verified.

[In]

Integrate[Sin[c + d*x]^2/(a + b*Tan[c + d*x]),x]

[Out]

-(2*a*b*(a^2 + b^2)*ArcTan[Tan[c + d*x]] + 2*b^2*(a^2 + b^2)*Cos[c + d*x]^2 + a*(2*a*((b^2 + a*Sqrt[-b^2])*Log
[Sqrt[-b^2] - b*Tan[c + d*x]] - 2*b^2*Log[a + b*Tan[c + d*x]] + (b^2 - a*Sqrt[-b^2])*Log[Sqrt[-b^2] + b*Tan[c
+ d*x]]) + b*(a^2 + b^2)*Sin[2*(c + d*x)]))/(4*b*(a^2 + b^2)^2*d)

________________________________________________________________________________________

Maple [B]  time = 0.059, size = 238, normalized size = 2.5 \begin{align*} -{\frac{{a}^{3}\tan \left ( dx+c \right ) }{2\,d \left ({a}^{2}+{b}^{2} \right ) ^{2} \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) }}-{\frac{a\tan \left ( dx+c \right ){b}^{2}}{2\,d \left ({a}^{2}+{b}^{2} \right ) ^{2} \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) }}-{\frac{b{a}^{2}}{2\,d \left ({a}^{2}+{b}^{2} \right ) ^{2} \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) }}-{\frac{{b}^{3}}{2\,d \left ({a}^{2}+{b}^{2} \right ) ^{2} \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) }}-{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ){a}^{2}b}{2\,d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{\arctan \left ( \tan \left ( dx+c \right ) \right ){a}^{3}}{2\,d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{\arctan \left ( \tan \left ( dx+c \right ) \right ) a{b}^{2}}{2\,d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{b{a}^{2}\ln \left ( a+b\tan \left ( dx+c \right ) \right ) }{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sin(d*x+c)^2/(a+b*tan(d*x+c)),x)

[Out]

-1/2/d/(a^2+b^2)^2/(1+tan(d*x+c)^2)*tan(d*x+c)*a^3-1/2/d/(a^2+b^2)^2/(1+tan(d*x+c)^2)*tan(d*x+c)*a*b^2-1/2/d/(
a^2+b^2)^2/(1+tan(d*x+c)^2)*b*a^2-1/2/d/(a^2+b^2)^2/(1+tan(d*x+c)^2)*b^3-1/2/d/(a^2+b^2)^2*ln(1+tan(d*x+c)^2)*
a^2*b+1/2/d/(a^2+b^2)^2*arctan(tan(d*x+c))*a^3-1/2/d/(a^2+b^2)^2*arctan(tan(d*x+c))*a*b^2+1/d*b*a^2/(a^2+b^2)^
2*ln(a+b*tan(d*x+c))

________________________________________________________________________________________

Maxima [A]  time = 1.5721, size = 194, normalized size = 2.06 \begin{align*} \frac{\frac{2 \, a^{2} b \log \left (b \tan \left (d x + c\right ) + a\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{a^{2} b \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac{{\left (a^{3} - a b^{2}\right )}{\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{a \tan \left (d x + c\right ) + b}{{\left (a^{2} + b^{2}\right )} \tan \left (d x + c\right )^{2} + a^{2} + b^{2}}}{2 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(d*x+c)^2/(a+b*tan(d*x+c)),x, algorithm="maxima")

[Out]

1/2*(2*a^2*b*log(b*tan(d*x + c) + a)/(a^4 + 2*a^2*b^2 + b^4) - a^2*b*log(tan(d*x + c)^2 + 1)/(a^4 + 2*a^2*b^2
+ b^4) + (a^3 - a*b^2)*(d*x + c)/(a^4 + 2*a^2*b^2 + b^4) - (a*tan(d*x + c) + b)/((a^2 + b^2)*tan(d*x + c)^2 +
a^2 + b^2))/d

________________________________________________________________________________________

Fricas [A]  time = 2.12276, size = 278, normalized size = 2.96 \begin{align*} \frac{a^{2} b \log \left (2 \, a b \cos \left (d x + c\right ) \sin \left (d x + c\right ) +{\left (a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + b^{2}\right ) +{\left (a^{3} - a b^{2}\right )} d x -{\left (a^{2} b + b^{3}\right )} \cos \left (d x + c\right )^{2} -{\left (a^{3} + a b^{2}\right )} \cos \left (d x + c\right ) \sin \left (d x + c\right )}{2 \,{\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )} d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(d*x+c)^2/(a+b*tan(d*x+c)),x, algorithm="fricas")

[Out]

1/2*(a^2*b*log(2*a*b*cos(d*x + c)*sin(d*x + c) + (a^2 - b^2)*cos(d*x + c)^2 + b^2) + (a^3 - a*b^2)*d*x - (a^2*
b + b^3)*cos(d*x + c)^2 - (a^3 + a*b^2)*cos(d*x + c)*sin(d*x + c))/((a^4 + 2*a^2*b^2 + b^4)*d)

________________________________________________________________________________________

Sympy [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: AttributeError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(d*x+c)**2/(a+b*tan(d*x+c)),x)

[Out]

Exception raised: AttributeError

________________________________________________________________________________________

Giac [B]  time = 1.14829, size = 248, normalized size = 2.64 \begin{align*} \frac{\frac{2 \, a^{2} b^{2} \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{a^{4} b + 2 \, a^{2} b^{3} + b^{5}} - \frac{a^{2} b \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac{{\left (a^{3} - a b^{2}\right )}{\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac{a^{2} b \tan \left (d x + c\right )^{2} - a^{3} \tan \left (d x + c\right ) - a b^{2} \tan \left (d x + c\right ) - b^{3}}{{\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}{\left (\tan \left (d x + c\right )^{2} + 1\right )}}}{2 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(d*x+c)^2/(a+b*tan(d*x+c)),x, algorithm="giac")

[Out]

1/2*(2*a^2*b^2*log(abs(b*tan(d*x + c) + a))/(a^4*b + 2*a^2*b^3 + b^5) - a^2*b*log(tan(d*x + c)^2 + 1)/(a^4 + 2
*a^2*b^2 + b^4) + (a^3 - a*b^2)*(d*x + c)/(a^4 + 2*a^2*b^2 + b^4) + (a^2*b*tan(d*x + c)^2 - a^3*tan(d*x + c) -
 a*b^2*tan(d*x + c) - b^3)/((a^4 + 2*a^2*b^2 + b^4)*(tan(d*x + c)^2 + 1)))/d